<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE>
<html>
<head>
	<title>PayInfoConfig</title>
	<%@ include file="/WEB-INF/views/include/head.jsp"%>
</head>
<body>
	<%@ include file="/WEB-INF/views/include/loading.jsp"%>
	<!-- 数据列表  -->
	<div class="easyui-layout" data-options="fit:true,border:false">
		<div data-options="region:'center'">
			<table id="Grid" class="easyui-datagrid" ctrlSelect="true" striped="true"
				rownumbers="true" pagination="true" fitColumns="true" toolbar="#Grid_Toolbar"
				loadMsg="正在加载数据，请稍等..." emptyMsg="没有找到符合条件的数据"
				data-options="url:'${ctx}/pay/payInfoConfig/list',fit:true, fitColumns:true, checkOnSelect:true, selectOnCheck:true, border: false">
			    <thead>
			        <tr>
			            <th data-options="field:'ck',checkbox:true"></th>
		            	<th data-options="field:'appid'">appid</th>
						
			            <th data-options="field:'payChannelName'">支付渠道名称</th>
			            <th data-options="field:'payName'">支付类型名称</th>
			            <th data-options="field:'merchantId'">商户号</th>
			            <th data-options="field:'merchantName'">支付号名称</th>
			            <th data-options="field:'merchantCode'">商户号代码</th>
<!-- 			            <th data-options="field:'merchantKey'">商户号密钥</th> -->
<!-- 			            <th data-options="field:'keyStoreFile'">证书路径</th> -->
<!-- 			            <th data-options="field:'keyStorePassword'">证书密码</th> -->
<!-- 			            <th data-options="field:'requestUrl'">请求url</th> -->
<!-- 			            <th data-options="field:'notifyUrl'">回调地址</th> -->
<!-- 			            <th data-options="field:'backUrl'">前置通知</th> -->
<!-- 			            <th data-options="field:'frontUrl'">后置通知</th> -->
<!-- 			            <th data-options="field:'isDelete'">是否删除</th> -->
			            <th data-options="field:'createBy'">创建人</th>
			            <th data-options="field:'createDate'">创建时间</th>
			            <th data-options="field:'updateBy'">修改人</th>
			            <th data-options="field:'updateDate'">修改时间</th>
			            <th data-options="field:'remarks'">备注</th>
			        </tr>
			    </thead>
			</table>
			<div id="Grid_Toolbar">
				<div class="pull-left">
					<form id="searchForm">
						<shiro:hasPermission name="payInfoConfig:query">
							<select class="easyui-combobox" name="payChannelId" id="payChannelId" 
							data-options="width:120,editable:false,value:null,prompt:'支付渠道'">
								<c:forEach items="${payChannelList}" var="pc">
									<option value="${pc.id}">${pc.payChannelName}</option>
								</c:forEach>
							</select>
							<select class="easyui-combobox" name="payTypeId" id="payTypeId" 
								data-options="width:120,editable:false,value:null,prompt:'支付类型'">
								<c:forEach items="${payTypeList}" var="pt">
									<option value="${pt.id}">${pt.payName}</option>
								</c:forEach>
							</select> 
				        	<a id="btnSearch" href="javascript:void(0)" class="easyui-linkbutton button-primary"><i class="fa fa-search fa-lg"></i>&nbsp;&nbsp;查询</a>
				    		<a href="javascript:void(0)" id="reset_btn" class="easyui-linkbutton reset l-btn l-btn-small" plain="true" ><i class="fa fa-repeat fa-lg"></i>&nbsp;&nbsp;重置</a>
				    	</shiro:hasPermission>
					</form>	
			    </div>
			    <div class="pull-right">
		    		<shiro:hasPermission name="payInfoConfig:create">
			       		<a id="btnCreate" href="javascript:void(0)" class="easyui-linkbutton button-success"><i class="fa fa-plus-circle fa-lg"></i>&nbsp;&nbsp;新增</a>
					</shiro:hasPermission>
					
					<shiro:hasPermission name="payInfoConfig:update">
				        <a id="btnUpdate" href="javascript:void(0)" class="easyui-linkbutton button-default"><i class="fa fa-pencil fa-lg"></i>&nbsp;&nbsp;修改</a>
					</shiro:hasPermission>
					
					<shiro:hasPermission name="payInfoConfig:delete">
				        <a id="btnDelete" href="javascript:void(0)" class="easyui-linkbutton button-danger"><i class="fa fa-minus-circle fa-lg"></i>&nbsp;&nbsp;删除</a>
					</shiro:hasPermission>
				</div>
		    </div>
		</div>
	</div>
	
    <!-- js脚本，必须写在body中，tab的url加载模式只会异步加载body中的内容到tab中 -->
	<script type="text/javascript">
		require(['jquery','common'], function($){
			// 给新增按钮添加点击事件
			$("#btnCreate").on('click', function(){
				showDialog('新增', '${ctx}/pay/payInfoConfig/add', 800, 600, function () {
					$('#Grid').datagrid('reload');
				});
			});
			
			// 给修改按钮添加点击事件
			$("#btnUpdate").on('click', function(){
				var selected = $("#Grid").datagrid('getSelections');
				if(selected.length == 0){
					$.messager.alert('提示','请选择需要修改的记录', "info");
				}
				if(selected.length > 1){
					$.messager.alert('提示','只能选择一条需要修改的记录', "info");
				}
				if(selected.length == 1){
					showDialog('编辑', '${ctx}/pay/payInfoConfig/edit?id=' + selected[0].id, 850, 580, function () {
						$('#Grid').datagrid('reload');
					});
				}
			});
			
			// 给删除按钮添加点击事件
			$("#btnDelete").on('click', function(){
				var selected = $("#Grid").datagrid('getSelections');
				if(selected.length == 0){
					$.messager.alert('提示','请选择需要删除的记录', "info");
				}else{
                    $.messager.confirm('警告', '确认删除本条记录吗?', function (r) {
                        if(r){
                            var ids = '';
                            for (var i = 0; i < selected.length; i++) {
                                ids += selected[i].id + ',';
                            }
                            
                            $.ajax({
	                            url: '${ctx}/pay/payInfoConfig/delete',
	                            data: {
	                                ids: ids
	                            },
	                            type: 'post',
	                            dataType: 'json',
	                            success: function (json) {
	                                if (json && json.rtnCode == '00000000') {
	                                    $.messager.alert('提示', "删除成功", "success");
	                                    $('#Grid').datagrid('reload');
	                                } else {
	                                    $.messager.alert('提示', json.rtnMsg);
	                                }
	                            }
                        	});
						}
                    });
				}
			});
			
			// 清空查询表单，重载表格数据
			$('#reset_btn').click(function () {
				$('#searchForm').form('reset');
				reload();
			});
			
			// 给查询按钮添加点击事件
			$("#btnSearch").on('click', function(){
				if($('#searchForm').form('enableValidation').form('validate')){
					reload();
				}
			});
			
		});
		function reload(){
			var params = $('#Grid').datagrid('options').queryParams;
			params.payChannelId = $('#payChannelId').val();
			params.payTypeId = $('#payTypeId').val();
			$('#Grid').datagrid('options').queryParams = params;
			$('#Grid').datagrid('reload');
		}
	</script>
</body>
</html>